home *** CD-ROM | disk | FTP | other *** search
/ The Arsenal Files 8 / The Arsenal Files Collection #8 (Arsenal Computer) (1996).ISO / prg_gen / yg600w95.zip / BITLIST.H < prev    next >
C/C++ Source or Header  |  1996-10-06  |  4KB  |  121 lines

  1. //
  2. //    $Id: BITLIST.H 1.2 1996/06/17 22:01:30 Y.Roumazeilles Exp $
  3. //
  4. //    (C) 1992-93-94-95-96 Yves Roumazeilles
  5. //
  6.  
  7.  
  8. #ifndef    __BITLIST_H__
  9. #define    __BITLIST_H__    
  10.  
  11. #include    <memory.h>
  12. #include    <string.h>
  13.  
  14. #ifndef    T_BASE_TYPE
  15. # define    T_BASE_TYPE    unsigned long
  16. #endif
  17. #define    SZ_BASE_TYPE        sizeof(T_BASE_TYPE)
  18. #define    BITS_BASE_TYPE        (SZ_BASE_TYPE*8)
  19. #define    NUM_BASE_ELEM(x)    (x)->Size
  20.  
  21.  
  22. typedef    struct tagBList {
  23.     int            Size;
  24.     int            iWordSize;
  25.     int            bAllocated;
  26. #ifdef    NUMTAG
  27.     int            iTag;        /* temporary numbered tag */
  28. #endif
  29. #ifdef    WINVER
  30.     HANDLE            hBits;
  31.     T_BASE_TYPE FAR*    Bits;
  32. #else
  33.     T_BASE_TYPE*        Bits;
  34. #endif
  35. #ifdef    BL_CHECK
  36.     long            lTest;        /* temporary test pattern location */
  37. #endif
  38. } BLIST;
  39. #ifdef    WINVER
  40. typedef    BLIST*        PBLIST;
  41. typedef    BLIST FAR*    LPBLIST;
  42. #else
  43. typedef    BLIST*        PBLIST;
  44. typedef    BLIST*        LPBLIST;
  45. typedef int        BOOL;
  46. #define FALSE        0
  47. #define TRUE        1
  48. #endif
  49.  
  50.  
  51.  
  52. /* Basic operations declaration */
  53.  
  54. #define    INDEX_BIT(n)    ((n) / BITS_BASE_TYPE)
  55. #define    MASQUE_BIT(n)    (1L << ((n) % BITS_BASE_TYPE))
  56.  
  57.  
  58. #define    BSET(t, n)    (t).Bits[INDEX_BIT(n)] |= MASQUE_BIT(n)
  59. #define    BCHG(t, n)    (t).Bits[INDEX_BIT(n)] ^= MASQUE_BIT(n)
  60. #define    BCLR(t, n)    (t).Bits[INDEX_BIT(n)] &= ~MASQUE_BIT(n)
  61. #define    BTST(t, n)    ((t).Bits[INDEX_BIT(n)] & MASQUE_BIT(n))
  62. #define    BSET_unlocked(t, n)    BitListLock(&t);\
  63.                 (t).Bits[INDEX_BIT(n)] |= MASQUE_BIT(n);\
  64.                 BiTListUnlock(&t)
  65. #define    BCHG_unlocked(t, n)    BitListLock(&t);\
  66.                 (t).Bits[INDEX_BIT(n)] ^= MASQUE_BIT(n);\
  67.                 BiTListUnlock(&t)
  68. #define    BCLR_unlocked(t, n)    BitListLock(&t);\
  69.                 (t).Bits[INDEX_BIT(n)] &= ~MASQUE_BIT(n);\
  70.                 BiTListUnlock(&t)
  71. #define    BTST_unlocked(t, n)    BitListLock(&t);\
  72.                 ((t).Bits[INDEX_BIT(n)] & MASQUE_BIT(n));\
  73.                 BiTListUnlock(&t)
  74.  
  75. #ifdef    WINVER
  76. #ifdef    BITLIST_BUILD
  77. #define    BLCALL    FAR PASCAL
  78. #else
  79. #define    BLCALL    FAR
  80. #endif
  81. #else
  82. #define    BLCALL    
  83. #endif
  84. extern BOOL BLCALL    BitListIsDebug( void );
  85.  
  86. extern void BLCALL    BitListDebugOutput(LPBLIST x);
  87. extern void BLCALL    BitListClr(LPBLIST x);
  88. extern void BLCALL    BitListSet(LPBLIST x);
  89. extern void BLCALL    BitListChg(LPBLIST x);
  90. extern int BLCALL    BitListCtorClr(LPBLIST x, int n);
  91. #define    BitListCtor(x,n)    BitListCtorClr(x,n);
  92. extern int BLCALL    BitListCtorSet(LPBLIST x, int n);
  93. extern int BLCALL    BitListEmpty(LPBLIST x);
  94. extern void BLCALL    BitListCopy(LPBLIST x, LPBLIST y);
  95. extern int BLCALL    BitListCopyCtor(LPBLIST x, LPBLIST y, int n);
  96. extern void BLCALL    BitListLShift(LPBLIST x, int n);
  97. extern void BLCALL    BitListRShift(LPBLIST x, int n);
  98. extern void BLCALL    BitListOr(LPBLIST x, LPBLIST y);
  99. extern void BLCALL    BitListCopyOr(LPBLIST x, LPBLIST y, LPBLIST z);
  100. extern void BLCALL    BitListAnd(LPBLIST x, LPBLIST y);
  101. extern void BLCALL    BitListCopyAnd(LPBLIST x, LPBLIST y, LPBLIST z);
  102. extern void BLCALL    BitListAndNot(LPBLIST x, LPBLIST y);
  103. extern void BLCALL    BitListOrNot(LPBLIST x, LPBLIST y);
  104. extern void BLCALL    BitListNot(LPBLIST x);
  105. extern void BLCALL    BitListAdd(LPBLIST x, LPBLIST y);
  106. extern void BLCALL    BitListSub(LPBLIST x, LPBLIST y);
  107. extern void BLCALL    BitListMultiply(LPBLIST x, LPBLIST y);    /* not implemented */
  108. extern void BLCALL    BitListDivide(LPBLIST x, LPBLIST y);    /* not implemented */
  109. extern int BLCALL    BitListEqual(LPBLIST x, LPBLIST y);
  110. extern int BLCALL    BitListEqualZero(LPBLIST x);
  111. extern int BLCALL    BitListCompare(LPBLIST x, LPBLIST y);
  112. #ifdef    WINVER
  113. extern int BLCALL    BitListLock(LPBLIST x);
  114. extern int BLCALL    BitListUnlock(LPBLIST x);
  115. #else
  116. #define    BitListLock(x)
  117. #define    BitListUnlock(x)
  118. #endif
  119.  
  120. #endif    /* __BITLIST_H__ */
  121.